// 目录表

const { STRING } = require("sequelize");

const sequelize = require("../sequelize");

const catalogue = sequelize.define("catalogue", {
    title: {
        type: STRING(50),
        allowNull: false,
        unique: true,
        comment: "目录名称"
    },
    createdate: {
        type: STRING,
        comment: "创建时间"
    },
    updated: {
        type: STRING,
        comment: "修改时间"
    },
    creator: {
        type: STRING,
        comment: "添加者"
    },
    updator: {
        type: STRING,
        comment: "修改者"
    },
}, {
    underscored: true,
    timestamps: false
})

const chapter = require("./chapter") // 章
catalogue.associate = () => {
}
catalogue.associate = () => {

    catalogue.hasMany(chapter, {
        foreginKey: "catalogueId",
        targetKey: "id"
    })
}


module.exports = catalogue